import "./assets/main.css";

import { createApp } from "vue";
import { createPinia } from "pinia";
import { useRouteStore } from "@/stores/routeStore";
import App from "./App.vue";
import router from "./router";
import axios from "@/request/axios";
import ElementPlus from "element-plus";
import * as ElIcon from "@element-plus/icons-vue"; // 引入所有图标
import "element-plus/dist/index.css";
//@ts-ignore忽略当前文件ts类型的检测否则有红色提示(打包会失败)
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import ganttastic from "@infectoone/vue-ganttastic";
// 引入unocss.css
import "virtual:uno.css";

const app = createApp(App);
const pinia = createPinia();
// console.log('router', router)
// console.log('router-2', router.options.routes)
app.use(pinia);
app.use(router);
app.use(ganttastic);

Object.keys(ElIcon).forEach((key) => {
	app.component(ElIcon[key].name, ElIcon[key]);
});

// 集成-element-plus
app.use(ElementPlus, {
	locale: zhCn, //设置中文
});

// 保存路由数据到 Pinia
const routeStore = useRouteStore();
const sourceRoutes = JSON.parse(JSON.stringify(router.options.routes));
routeStore.setRoutes(sourceRoutes);

app.mount("#app");
app.config.globalProperties.$api = axios;
